Sub セルの罫線設定()
'********************************************
'線のスタイル確認
'********************************************
'B2に実線
With Range("B2").Borders
.LineStyle = xlContinuous
End With
'B4に波線
With Range("B4").Borders
.LineStyle = xlDash
End With
'B6に一点鎖線
With Range("B6").Borders
.LineStyle = xlDashDot
End With
'B8に二点鎖線
With Range("B8").Borders
.LineStyle = xlDashDotDot
End With
'B10に点線
With Range("B10").Borders
.LineStyle = xlDot
End With
'B12に二重線
With Range("B12").Borders
.LineStyle = xlDouble
End With
'B14に斜めの線での点線
With Range("B14").Borders
.LineStyle = xlSlantDashDot
End With
'B16に線なし(設定されているのを解除する場合)
With Range("B16").Borders
.LineStyle = xlLineStyleNone
End With
'********************************************
'線の太さ確認
'********************************************
'D2に極細線
With Range("D2").Borders
.Weight = xlHairline
End With
'D4に細線
With Range("D4").Borders
.Weight = xlThin
End With
'D6に中線
With Range("D6").Borders
.Weight = xlMedium
End With
'D8に太線
With Range("D8").Borders
.Weight = xlThick
End With
'********************************************
'設定する線の位置確認
'********************************************
'F2の上辺
With Range("F2").Borders(xlEdgeTop)
.LineStyle = xlSolid
.Weight = xlMedium
End With
'F4の下の辺
With Range("F4").Borders(xlEdgeBottom)
.LineStyle = xlSolid
.Weight = xlMedium
End With
'F6の右の辺
With Range("F6").Borders(xlEdgeRight)
.LineStyle = xlSolid
.Weight = xlMedium
End With
'F8の左の辺
With Range("F8").Borders(xlEdgeLeft)
.LineStyle = xlSolid
.Weight = xlMedium
End With
'F10の斜めの線(左上から右下)
With Range("F10").Borders(xlDiagonalDown)
.LineStyle = xlSolid
.Weight = xlMedium
End With
'F12の斜めの線(左下から右上)
With Range("F12").Borders
.LineStyle = xlSolid
.Weight = xlMedium
End With
'F14:G:15の内側の水平線
With Range("F14:G15").Borders(xlInsideHorizontal)
.LineStyle = xlSolid
.Weight = xlMedium
End With
'F17:G18の内側の垂直線
With Range("F17:G18").Borders(xlInsideVertical)
.LineStyle = xlSolid
.Weight = xlMedium
End With
'********************************************
'指定した罫線の色を使用するには
'********************************************
'I2のセルを赤色の線、I4のセルを青色の線で囲む
With Range("I2").Borders
.Color = RGB(255, 0, 0)
.LineStyle = xlSolid
.Weight = xlMedium
End With
With Range("I4").Borders
.Color = RGB(0, 0, 255)
.LineStyle = xlSolid
.Weight = xlMedium
End With
End Sub